package ink.tiptop.controller;

import ink.tiptop.persist.domain.entity.ZjfUserModuleVersionEntity;
import ink.tiptop.dto.req.version.AddZjfUserModuleVersionRequest;
import ink.tiptop.dto.req.version.DeleteZjfUserModuleVersionRequest;
import ink.tiptop.dto.req.version.QueryZjfUserModuleVersionRequest;
import ink.tiptop.dto.req.version.UpdateZjfUserModuleVersionRequest;
import ink.tiptop.common.domain.rsp.Response;
import ink.tiptop.service.ZjfUserModuleVersionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import ink.tiptop.utils.JSON;
/**
 * 用于用户-模块版本的映射
 * User:module = 1:n
 * (ZjfUserModuleVersionEntity)表控制层
 *
 * @author makejava
 * @since 2020-06-21 20:39:19
 */
@Api("用户版本API")
@RestController
@RequestMapping("zjfUserModuleVersion")
@Slf4j
public class UserModuleVersionController {
    /**
     * 服务对象
     */
    @Resource
    private ZjfUserModuleVersionService zjfUserModuleVersionService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("单一查询用户版本信息")
    @GetMapping("selectOne")
    public ZjfUserModuleVersionEntity selectOne(Integer id) {
        return this.zjfUserModuleVersionService.queryById(id);
    }

    /**
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("添加版本信息")
    @PostMapping("add")
    @ResponseBody
    public Response add(@RequestBody @Valid AddZjfUserModuleVersionRequest request) {
        log.info("添加版本信息,入参:{}", JSON.toJSONString(request));
        return this.zjfUserModuleVersionService.add(request);
    }

    @ApiOperation("查询版本信息列表信息")
    @PostMapping("list")
    @ResponseBody
    public Response list(@RequestBody QueryZjfUserModuleVersionRequest request) {
        log.info("查询版本信息列表信息,入参:{}", JSON.toJSONString(request));
        return this.zjfUserModuleVersionService.list(request);
    }

    @ApiOperation("更新版本信息")
    @PostMapping("update")
    @ResponseBody
    public Response update(@RequestBody @Valid UpdateZjfUserModuleVersionRequest request) {
        log.info("更新版本信息,入参:{}", JSON.toJSONString(request));
        return this.zjfUserModuleVersionService.update(request);
    }

    @ApiOperation("批量删除版本信息")
    @PostMapping("delete")
    @ResponseBody
    public Response delete(@RequestBody @Valid DeleteZjfUserModuleVersionRequest request) {
        log.info("批量删除版本信息,入参:{}", JSON.toJSONString(request));
        return this.zjfUserModuleVersionService.deleteAll(request);
    }

}